package com.lcf.demo;

public class Rectangle {
//    定义属性
    private double length;
    private double  width;
//定义无参构造
    public Rectangle() {
    }
//    定会有参构造

    public Rectangle(double length, double width) {
        this.length = length;
        this.width = width;
    }
//    调用set get 方法

    public double getLength() {
        return length;
    }

    public void setLength(double length) {
        this.length = length;
    }

    public double getWidth() {
        return width;
    }

    public void setWidth(double width) {
        this.width = width;
    }
    public double getArea(){
        return length * width;
    }
    public double getPerimeter(){
        return 2 * (length + width);
    }
    public String getInfo(){
        return "长：" + length + "，宽：" + width + "，面积：" + getArea() + "，周长：" + getPerimeter();
    }
}

